<template>
  <page-header-wrapper>
    <a-card>
      <GzSearchForm :searchFunc="queryhFunc" :resetFunc="() => { searchData = {} }">
        <a-form-item class="table-search-item" label="任务名称">
          <a-input v-model:value="searchData['scheduledName']" :placeholder="'活动编号'" />
        </a-form-item>
        <!-- 方法名methodName -->
        <a-form-item class="table-search-item" label="状态">
          <a-select v-model:value="searchData['status']" placeholder="请选择状态">
            <a-select-option value="PROCESSING">正在处理</a-select-option>
            <a-select-option value="SUCCESS">执行成功</a-select-option>
            <a-select-option value="FAILED">执行失败</a-select-option>
          </a-select>
        </a-form-item>
      </GzSearchForm>

      <!-- 列表渲染 -->
      <GzTable
        ref="infoTableRef"
        :init-data="true"
        :req-table-data-func="reqTableDataFunc"
        :table-columns="tableColumns"
        :search-data="searchData"
        row-key="sysScheduledLogId"
      >
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'status'">
            <a-tag
              :key="record.status"
              :color="record.status === 'PROCESSING' ? 'blue' : record.status === 'SUCCESS' ? 'green' : 'red'"
            >
              {{ record.status === 'PROCESSING' ? '正在处理' : record.status === 'SUCCESS' ? '执行成功' : '执行失败' }}
            </a-tag>
          </template>
        </template>
      </GzTable>
    </a-card>
  </page-header-wrapper>
</template>
<script lang="ts" setup>
import { $getSysScheduledLog, } from '@/api/sysManage/taskLog/index'

import { ref, reactive, getCurrentInstance, onMounted } from 'vue'

const { $infoBox } = getCurrentInstance()!.appContext.config.globalProperties

const infoTableRef = ref()

let tableColumns = [
  { title: '任务名称', key: 'scheduledName', dataIndex: 'scheduledName', width: 200, },
  { title: '状态', key: 'status', dataIndex: 'status', width: 100, },
  { title: '方法名', key: 'methodName', dataIndex: 'methodName', width: 150, },
  { title: 'cron执行表达式', key: 'cronExpression', dataIndex: 'cronExpression', width: 200, },
  { title: '错误信息', key: 'errorMsg', dataIndex: 'errorMsg', width: 100, },
  { title: '开始时间', key: 'createdAt', dataIndex: 'createdAt', width: 180, },
  { title: '完成时间', key: 'completedTime', dataIndex: 'completedTime', width: 180, },

]
// 列表表头

const searchData: any = ref({})

function queryhFunc() {
   infoTableRef.value.refTable(true)
}
function reqTableDataFunc(params: any) {
  return $getSysScheduledLog(params)
}


</script>
